<!--短信模块：1.我的短信  2.所有短信  3.群发短信  4.导入群发短信  5.短信模板管理  by 洪文-->
<template>
  <div class="sms" >
    <el-tabs v-model="activeName" :active-name="activeName" @tab-click="tab">
      <el-tab-pane :label="$t('sms.mySMS')" name="my" v-if="menuData[0].isShow">
        <sms-my :refresh="refresh"></sms-my>
      </el-tab-pane>
      <el-tab-pane :label="$t('sms.allSMS')" name="all" v-if="menuData[1].isShow">
        <sms-all :refresh="refresh"></sms-all>
      </el-tab-pane>
      <el-tab-pane :label="$t('sms.massSMS')" name="mass" v-if="menuData[2].isShow">
        <sms-mass :refresh="refresh"></sms-mass>
      </el-tab-pane>
      <el-tab-pane :label="$t('sms.importSMS')" name="import" v-if="menuData[3].isShow">
        <sms-import :refresh="refresh"></sms-import>
      </el-tab-pane>
    </el-tabs>
    <div></div>
  </div>
</template>
<script>
  import {isHasMenu} from '@/utils/m7Utils.js'
  import smsMy from '@/components/business-modules/sms/SmsMy.vue'
  import smsAll from '@/components/business-modules/sms/SmsAll.vue'
  import smsMass from '@/components/business-modules/sms/SmsMass.vue'
  import smsImport from '@/components/business-modules/sms/SmsImport.vue'
  import { addZhuGeTrack } from '@/utils/addZhuGeTrack.js'
  export default {
    name: 'sms',
    data () {
      return {
        firstActiveName: 'my',
        activeName: 'my',
        refresh: 'my',
        menuData: [
          {name: 'my_sms', isShow: false, disName: 'my'},
          {name: 'all_sms', isShow: false, disName: 'all'},
          {name: 'batch_send_sms', isShow: false, disName: 'mass'},
          {name: 'import_batch_send_sms', isShow: false, disName: 'import'} // ,
          // {name: 'sms_template_query', isShow: false, disName: 'template'}
        ]
      }
    },
    methods: {
      tab (tab) {
        this.refresh = tab.name
        addZhuGeTrack(tab.name)
      },
      initMenu () {
        this.menuData.forEach(item => {
          if (isHasMenu(item.name, this.$store.state.session.user)) {
            item.isShow = true
          }
        })
      }
    },
    components: {
      smsMy,
      smsAll,
      smsMass,
      smsImport
    },
    activated () {
      this.activeName = this.firstActiveName
      this.refresh = this.firstActiveName
      this.$router.push({path: '/index/sms'})
    },
    beforeMount () {
      this.initMenu()
      for (let i in this.menuData) {
        if (this.menuData[i].isShow === true) {
          this.firstActiveName = this.menuData[i].disName
          return
        }
      }
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../assets/common.styl"
  .sms
    height calc(100vh - 53px)
    background $cf-white
    padding-top 2px
    .smsMy
    .smsAll
    .smsMass
    .smsTemplate
      padding 20px
      height calc(100vh - 135px)
      overflow auto
    .smsImport
      padding 0 0 20px
      height calc(100vh - 95px)
  .el-tabs__item
    margin-left: 12px
</style>
